package com.yamidragut.simpleebooksreader;

import java.util.Comparator;

import com.dropbox.sync.android.DbxFileInfo;


public class Util {
	
	// Keys for the app to get linked with the Dropbox Sync Api
    public static final String appKey = "2hfa3myw0tsy01c";
    public static final String appSecret = "884d5gpbzway1gb";
    
    // It can be whichever number, but the same in the request and in the onActivityResult method
    public static final int REQUEST_LINK_TO_DBX = 0;
    
    public static final String EPUB_FILE = ".epub";
    public static final String COVER_PATH_EXTRA = "cover_path_extra";
    
    public static final String COVER_DIRECTORY = "temp_covers";
    public static final String COVER_FILE_EXTENSION = ".png";
    
    public static enum CURRENT_SORT_MODE {BY_TITLE, BY_DATE, NOT_SORTED};
    
	
	/**
	 * Comparators in order to sort the data 
	 */
	// Compare the data in a Collection by the number phone, the lower first
    public static Comparator<DbxFileInfo> SORT_BY_TITLE = new Comparator<DbxFileInfo>() {
        public int compare(DbxFileInfo one, DbxFileInfo other) {
            return one.path.compareTo(other.path);
        }
    };

    // Compare the data in a Collection by the name of the user alphabetically
    public static Comparator<DbxFileInfo> SORT_BY_DATE = new Comparator<DbxFileInfo>() {
        public int compare(DbxFileInfo one, DbxFileInfo other) {
            return one.modifiedTime.compareTo(other.modifiedTime);
        }
    };
    
    
    // Eliminates the extension
    static String stripExtension(String extension, String filename) {
        
        if (filename.endsWith(extension)) {
            return filename.substring(0, filename.length() - extension.length());
        }
        return filename;
    }

}
